#![allow(dead_code)]
/// 元组是有限异构序列。
pub struct TupleLrn {}

impl TupleLrn {
    fn hello() {
        println!("Tuple learning!");
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn test_basic() {
        let tup = ("hello", 5, 'c');
        assert_eq!(tup.0, "hello");
    }

    #[test]
    fn test_extend() {
        let mut tuple = (vec![0], vec![1]);
        tuple.extend([(2, 3), (4, 5), (6, 7)]);
        assert_eq!(tuple.0, [0, 2, 4, 6]);
        assert_eq!(tuple.1, [1, 3, 5, 7]);

        let mut nested_tuple = (vec![1], (vec![2], vec![3]));
        nested_tuple.extend([(4, (5, 6)), (7, (8, 9))]);

        let (a, (b, c)) = nested_tuple;
        assert_eq!(a, [1, 4, 7]);
        assert_eq!(b, [2, 5, 8]);
        assert_eq!(c, [3, 6, 9]);
    }

    #[test]
    fn test_modify() {
        let mut tuple = (1, 2, 3);
        tuple.0 = 4;
        assert_eq!(tuple, (4, 2, 3));
    }
}

